package com.itcc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;


//配置视图解析器
@Configuration
public class WebMvcViewConfig implements WebMvcConfigurer {

    @Bean   //视图解析器
    public ViewResolver viewResolver(){
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        // 设置视图解析器的前缀，用于指定视图资源的存放目录
        resolver.setPrefix("/WEB-INF/views/");
        // 设置视图解析器的后缀，用于指定视图资源的文件类型
        resolver.setSuffix(".jsp");
        return resolver;
    }

}
